package com.zhida84.Servlet;
/**
 * 
 * @author shazhengbo sunchangxing
 *
 */
import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class personalServlet
 */
public class personalServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public personalServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		response.setContentType("text/html;charset=GBK");
		response.setContentType("text/html;charset=utf-8");
		String nid = null;
		try {
			Cookie[] cookies = request.getCookies();
			if (cookies != null) {
				for (Cookie c : cookies) {
					if (c.getName().equals("phone")) {
						nid = c.getValue();
					}
				}
				if (nid == null) {
					RequestDispatcher rd = request
							.getRequestDispatcher("User/login.jsp");
					rd.forward(request, response);
				} else {
					request.setAttribute("pid", nid);
					RequestDispatcher rd = request
							.getRequestDispatcher("User/personal/personal.jsp");
					rd.forward(request, response);
				}
			}
		} catch (Exception e) {
			RequestDispatcher rd = request
					.getRequestDispatcher("User/login.jsp");
			rd.forward(request, response);
		}
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
	}

}
